home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / hsc / source / hsclib / hscprc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-02  |  17.1 KB  |  435 lines

  1. /*
  2.  * This source code is part of hsc, a html-preprocessor,
  3.  * Copyright (C) 1995-1997  Thomas Aglassinger
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20. /*
  21.  * hsclib/hscprc.h
  22.  *
  23.  * hsc process structure
  24.  *
  25.  */
  26.  
  27. #ifndef HSC_HSCPRC_H
  28. #define HSC_HSCPRC_H
  29.  
  30. #include <time.h>
  31.  
  32. #include "hsclib/ldebug.h"
  33. #include "hsclib/tag.h"
  34.  
  35. #include "hscprj/project.h"
  36.  
  37. /*
  38.  * system-dependant defines
  39.  */
  40. #ifdef AMIGA
  41. #define CONFIG_FILE "hsc.prefs"
  42. #define OPTION_FILE "hsc.options", "env:hsc.options"
  43. #define CONFIG_PATH "PROGDIR:"
  44.  
  45. #define UNIX 1                  /* utilise POSIX-layer of BeOS */
  46. #elif defined RISCOS
  47. #define CONFIG_FILE "hsc:hsc.prefs"
  48. #define CONFIG_PATH "hsc:"
  49. #define OPTION_FILE "hsc.options"
  50.  
  51. #elif (defined NEXTSTEP) || (defined UNIX) || (defined BEOS)
  52. #define CONFIG_FILE "hsc.prefs"
  53. #define CONFIG_PATH "/usr/local/lib/", "/usr/lib/"
  54. #define OPTION_FILE "hsc.options"
  55.  
  56. /* [3] */
  57. #else
  58. #error "Operating system not supported: config-file/path"
  59. #endif
  60.  
  61. /* utilise POSIX-layer of BEOS */
  62. #if defined BEOS
  63. #define UNIX 1
  64. #endif
  65.  
  66. /* step sizes for expstr's */
  67. #define ES_STEP_MACRO   1024    /* tag_macro.c */
  68. #define ES_STEP_INFILE  4096    /* input file buffer */
  69.  
  70. /*
  71.  * modes for syntax check
  72.  */
  73. #define MODE_PEDANTIC 1
  74. #define MODE_NORMAL   2
  75. #define MODE_RELAXED  3
  76.  
  77. /*
  78.  * modes for attribute quotes
  79.  */
  80. #define QMODE_KEEP   1          /* keep quotes from input */
  81. #define QMODE_DOUBLE 2          /* always use double quotes (compatible) */
  82. #define QMODE_SINGLE 3          /* always use single quotes */
  83. #define QMODE_NONE   4          /* never use any quotes (compact) */
  84.  
  85. /*
  86.  * modes for special characters/entity extraction
  87.  */
  88. #define EMODE_KEEP     1        /* do not replace */
  89. #define EMODE_REPLACE  2        /* replace by prefered value */
  90.                                 /*   (depends wheter if a PREFNUM was used */
  91.                                 /*   within $DEFENT) */
  92. #define EMODE_NUMERIC  3        /* always replace by numeric ({) */
  93. #define EMODE_SYMBOLIC 4        /* always replace by symbolic (ü) */
  94.  
  95. /*
  96.  * misc. defines for files & envvars
  97.  */
  98. #define ENV_HSCPATH    "HSCPATH"        /* envvar that contains path for prefs */
  99. #define ENV_HSCSALARY  "HSCSALARY"      /* contains salary of user */
  100. #define ENV_HSCUSER    "HSCUSER_PATH"   /* to substitute "~/" */
  101. #define ENV_HSCUSERS   "HSCUSERS_PATH"  /* to substitute "~" */
  102. #define ENV_HSCROOT    "HSCROOT_PATH"   /* to substitute "/" */
  103.  
  104. /* used as prefix in filename for
  105.  * internal (pseudo-)files (macros,init) */
  106. #define SPECIAL_FILE_ID "::s::"
  107.  
  108. /* prefix to be used by filenames if parent file on input-stack
  109.  * should be used for message-pos.
  110.  *
  111.  * NOTE: this is set if IH_POS_PARENT is passed on hsc_include() */
  112. #define PARENT_FILE_ID  "::p::"
  113.  
  114. /* pseudo-filename for stdin */
  115. #define FILENAME_STDIN "STDIN"
  116.  
  117. /* prefix char used for special hsc-tags  */
  118. #define HSC_SPECIAL_PREFIX "$"
  119.  
  120. /* names for special attributes */
  121. #define CLICK_HERE_ATTR     "HSC.CLICK-HERE"    /* attribute that holds "click here" words */
  122. #define COLOR_NAMES_ATTR    "HSC.COLOR-NAMES"
  123. #define CONTENT_ATTR        "HSC.CONTENT"       /* keep macro content for content macros */
  124. #define ANCHOR_ATTR         "HSC.ANCHOR"
  125. #define RESULT_ATTR         "HSC.EXEC.RESULT"
  126. #define FILESIZEFORMAT_ATTR "HSC.FORMAT.FILESIZE"
  127. #define TIMEFORMAT_ATTR     "HSC.FORMAT.TIME"
  128. #define LINEFEED_ATTR       "HSC.LF"
  129.  
  130. /* attribute that hold condition on <$if/$elseif> */
  131. #define CONDITION_ATTR "COND"
  132.  
  133. /* attribute that tells operating system */
  134. #define SYSTEM_ATTR     "hsc.System"
  135. #ifdef AMIGA
  136. #define SYSTEM_ATTR_ID "Amiga"
  137.  
  138. #elif defined BEOS
  139. #define SYSTEM_ATTR_ID "BeOS"
  140.  
  141. #elif defined RISCOS
  142. #define SYSTEM_ATTR_ID "RiscOS"
  143.  
  144. #elif defined NEXTSTEP
  145. #define SYSTEM_ATTR_ID "NeXTStep"
  146.  
  147. #elif defined UNIX
  148. #define SYSTEM_ATTR_ID "Unix"
  149.  
  150. /* dos4 */
  151. #else
  152. #error "system not supported: SYSTEM_ATTR_ID"
  153. #endif
  154.  
  155. /*
  156.  * some typedefs used inside the hsc_process
  157.  */
  158. typedef LONG HSCMSG_ID;         /* hsc message id */
  159. typedef LONG HSCMSG_CLASS;      /* hsc message class */
  160.  
  161. /* enumerator values for hsc_process->msg_ignore */
  162. enum hsc_ignore_status
  163. {
  164.     make_my_day,                /* ignore only, if whole class is ignored */
  165.     ignore,                     /* always ignore */
  166.     enable                      /* always show up (even if class ignored) */
  167. };
  168.  
  169. typedef enum hsc_ignore_status HSCIGN;
  170.  
  171. /*
  172.  * hsc process structure
  173.  */
  174. struct hsc_process
  175. {
  176.     INFILE *inpf;               /* current input file */
  177.     DLLIST *inpf_stack;         /* stack of nested input files */
  178.     DLLIST *deftag;             /* defined tags and macros */
  179.     DLLIST *defattr;            /* defined attributes */
  180.     DLLIST *defent;             /* defined special charcters & entities */
  181.     DLLIST *deflazy;            /* defined lazy attribute lists */
  182.     DLLIST *container_stack;    /* stack of container-tags currently open */
  183.     DLLIST *content_stack;      /* stack of contents of container macros */
  184.     DLLIST *include_dirs;       /* include directories */
  185.     HSCPRJ *project;            /* project data */
  186.     DLLIST *idrefs;             /* list of references to local IDs */
  187.     EXPSTR *destdir;            /* destination root directory */
  188.     EXPSTR *reldir;             /* relative destination directory */
  189.     EXPSTR *tmpstr;             /* temp. string used by several functions */
  190.     EXPSTR *curr_msg;           /* current message */
  191.     EXPSTR *curr_ref;           /* current reference message */
  192.     EXPSTR *iconbase;           /* base URI for icons */
  193.     EXPSTR *server_dir;         /* root dir for server-relative URIs */
  194.     time_t start_time;          /* time process has been started */
  195.  
  196.     DLLIST *select_stack;       /* stack for results of <$select> */
  197.     EXPSTR *if_stack;           /* stack for results of <$if> */
  198.  
  199.     EXPSTR *tag_name_str;       /* strings for communication with tag-handlers */
  200.     EXPSTR *tag_attr_str;
  201.     EXPSTR *tag_close_str;
  202.  
  203.     STRPTR filename_document;   /* document-name to be stored in project */
  204.  
  205.     HSCIGN *msg_ignore;         /* messages to be ignored */
  206.     BOOL msg_ignore_notes;      /* message-classes to be ignores */
  207.     BOOL msg_ignore_style;
  208.     BOOL msg_ignore_port;
  209.     HSCMSG_CLASS *msg_class;    /* messages with remaped classes */
  210.     ULONG msg_count;            /* numer of messages occured until now */
  211.  
  212.     BOOL chkid;                 /* flag: check existence of URIs/IDs */
  213.     BOOL chkuri;
  214.     BOOL compact;               /* flag: create compact output */
  215.     BOOL debug;                 /* flag: display debuging info */
  216.     BOOL getsize;               /* flag: get size of images/embedded docs */
  217.  
  218.     BOOL htmlonly;              /* flag: disable hsc-extensions */
  219.     BOOL jens;                  /* flag: enable some experimental features */
  220.     BOOL jerkvalues;            /* flag: interpret jerk values */
  221.     BOOL rplc_ent;              /* flag: replace special chars */
  222.     BOOL rplc_quote;            /* flag: replace quotes in text by """ */
  223.     BOOL smart_ent;             /* flag: replace special entities "<>&" */
  224.     BOOL strip_cmt;             /* flag: strip SGML-comments */
  225.     BOOL strip_ext;             /* flag: strip external references */
  226.     BOOL strip_badws;           /* flag: strip bad white spaces */
  227.     BOOL weenix;                /* flag: unix compatibilty mode */
  228.     BOOL suppress_output;       /* flag: TRUE, until outputable data occure */
  229.     BOOL docbase_set;           /* <BASE HREF=".."> occured */
  230.     BOOL inside_pre;            /* inside preformatted tag <PRE> & Co. */
  231.     BOOL inside_anchor;         /* inside anchor-tag <A> */
  232.     BOOL inside_title;          /* inside title-tag <TITLE> */
  233.     BOOL prostitute;            /* use "prostitute" or "jerk"? */
  234.  
  235.     BOOL fatal;                 /* fatal error occured; abort process */
  236.  
  237.     LONG tag_call_id;
  238.     ULONG prev_status_line;
  239.     LONG prev_heading_num;      /* number of previous heading */
  240.     LONG entmode;               /* entity replace mode */
  241.     LONG quotemode;             /* quotes to use as output quotes */
  242.  
  243.     STRPTR click_here_str;      /* keywords for click-here syndrome */
  244.     STRPTR color_names;         /* predifined names for colors */
  245.     STRPTR strip_tags;          /* tags that should be stripped */
  246.     EXPSTR *whtspc;             /* white spaces buffered */
  247.     HSCTAG *tag_next_whtspc;    /* set, if a tag did not allow succ.whtspc */
  248.     BOOL strip_next_whtspc;     /* flag: strip next whtite space
  249.                                  * set by parse_tag(), if strip_badws = TRUE */
  250.     BOOL strip_next2_whtspc;    /* flag: strip next but one white space */
  251.     /* status callbacks */
  252.       VOID(*CB_status_misc) (struct hsc_process * hp, STRPTR s);
  253.     /* called for verbose messages */
  254.       VOID(*CB_status_line) (struct hsc_process * hp);
  255.     /* called after new line */
  256.       VOID(*CB_status_file_begin) (struct hsc_process * hp, STRPTR filename);
  257.     /* called when new file is going to be loaded */
  258.       VOID(*CB_status_file_end) (struct hsc_process * hp);
  259.     /* called after file has fully been processed */
  260.  
  261.     /* message callbacks */
  262.       VOID(*CB_message) (struct hsc_process * hp,
  263.                          HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
  264.                          STRPTR fname, ULONG x, ULONG y,
  265.                          STRPTR msg_text);
  266.       VOID(*CB_message_ref) (struct hsc_process * hp,
  267.                              HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
  268.                              STRPTR fname, ULONG x, ULONG y,
  269.                              STRPTR msg_text);
  270.  
  271.     /* syntax elements callbacks */
  272.       VOID(*CB_start_tag) (struct hsc_process * hp,
  273.           HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close);
  274.       VOID(*CB_end_tag) (struct hsc_process * hp,
  275.           HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close);
  276.       VOID(*CB_text) (struct hsc_process * hp,
  277.                       STRPTR white_spaces, STRPTR text);
  278.       VOID(*CB_id) (struct hsc_process * hp,
  279.                     HSCATTR * attr, STRPTR id);
  280.  
  281. #ifdef MSDOS
  282.     /* some compilers seem to have problems with this line.. */
  283.     enum content_called
  284.     {
  285.         no, once, often
  286.     };
  287. #endif
  288.  
  289. };
  290.  
  291. typedef struct hsc_process HSCPRC;
  292.  
  293. #if (!defined MSDOS) & ((defined WINNT))
  294. /* handle several OS-es same as MSDOS */
  295. #define MSDOS 1
  296. #error "Fuchs du hast die Gans gestohlen, gib sie wieder her..."
  297. #endif
  298.  
  299. /*
  300.  * global funcs
  301.  */
  302. #ifndef NOEXTERN_HSC_HSCPRC
  303.  
  304. #define anyWhtspc(hp) (estrlen(hp->whtspc))
  305.  
  306. extern VOID del_hscprc(HSCPRC * hp);
  307. extern HSCPRC *new_hscprc(void);
  308. extern VOID reset_hscprc(HSCPRC * hp);
  309.  
  310. /* set-methodes for callbacks */
  311. extern VOID hsc_set_status_file_begin(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp, STRPTR filename));
  312. extern VOID hsc_set_status_file_end(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp));
  313. extern VOID hsc_set_status_line(HSCPRC * hp, VOID(*status_line) (HSCPRC * hp));
  314. extern VOID hsc_set_status_misc(HSCPRC * hp, VOID(*status_misc) (HSCPRC * hp, STRPTR s));
  315. extern VOID hsc_set_message(HSCPRC * hp,
  316.                             VOID(*message) (struct hsc_process * hp,
  317.                                             HSCMSG_CLASS msg_class,
  318.                                             HSCMSG_ID msg_id,
  319.                                             STRPTR fname, ULONG x, ULONG y,
  320.                                             STRPTR msg_text));
  321. extern VOID hsc_set_message_ref(HSCPRC * hp,
  322.                                 VOID(*message_ref) (struct hsc_process * hp,
  323.                                                     HSCMSG_CLASS msg_class,
  324.                                                     HSCMSG_ID msg_id,
  325.                                                     STRPTR fname,
  326.                                                     ULONG x, ULONG y,
  327.                                                     STRPTR msg_text));
  328. extern VOID hsc_set_start_tag(HSCPRC * hp,
  329.                               VOID(*CB_start_tag) (struct hsc_process * hp,
  330.                                                    HSCTAG * tag,
  331.                                                    STRPTR tag_name,
  332.                                                    STRPTR tag_attr,
  333.                                                    STRPTR tag_close));
  334. extern VOID hsc_set_end_tag(HSCPRC * hp,
  335.                             VOID(*CB_end_tag) (struct hsc_process * hp,
  336.                                                HSCTAG * tag,
  337.                                                STRPTR tag_name,
  338.                                                STRPTR tag_attr,
  339.                                                STRPTR tag_close));
  340. extern VOID hsc_set_text(HSCPRC * hp,
  341.                          VOID(*CB_text) (struct hsc_process * hp,
  342.                                          STRPTR white_spaces, STRPTR text));
  343. extern VOID hsc_set_id(HSCPRC * hp,
  344.                        VOID(*id) (struct hsc_process * hp,
  345.                                   HSCATTR * attr, STRPTR id));
  346.  
  347. /* set-methodes for flags */
  348. extern VOID hsc_set_chkid(HSCPRC * hp, BOOL new_chkid);
  349. extern VOID hsc_set_chkuri(HSCPRC * hp, BOOL new_chkuri);
  350. extern VOID hsc_set_compact(HSCPRC * hp, BOOL new_compact);
  351. extern VOID hsc_set_debug(HSCPRC * hp, BOOL new_debug);
  352. extern VOID hsc_set_getsize(HSCPRC * hp, BOOL new_getsize);
  353. extern VOID hsc_set_htmlonly(HSCPRC * hp, BOOL new_jens);
  354. extern VOID hsc_set_jens(HSCPRC * hp, BOOL new_jens);
  355. extern VOID hsc_set_jerkvalues(HSCPRC * hp, BOOL new_jens);
  356. extern VOID hsc_set_rplc_ent(HSCPRC * hp, BOOL new_rplc_ent);
  357. extern VOID hsc_set_rplc_quote(HSCPRC * hp, BOOL new_rplc_quote);
  358. extern BOOL hsc_set_server_dir(HSCPRC * hp, STRPTR dir);
  359. extern VOID hsc_set_smart_ent(HSCPRC * hp, BOOL new_smart_ent);
  360. extern VOID hsc_set_strip_badws(HSCPRC * hp, BOOL new_strip_badws);
  361. extern VOID hsc_set_strip_cmt(HSCPRC * hp, BOOL new_strip_cmt);
  362. extern VOID hsc_set_strip_ext(HSCPRC * hp, BOOL new_strip_ext);
  363.  
  364. /* set-methodes for values */
  365. extern BOOL hsc_set_destdir(HSCPRC * hp, STRPTR dir);
  366. extern BOOL hsc_set_reldir(HSCPRC * hp, STRPTR fname);
  367. extern BOOL hsc_set_iconbase(HSCPRC * hp, STRPTR uri);
  368. extern BOOL hsc_set_strip_tags(HSCPRC * hp, STRPTR taglist);
  369. extern BOOL hsc_set_filename_document(HSCPRC * hp, STRPTR filename);
  370. extern VOID hsc_set_quote_mode(HSCPRC * hp, LONG new_mode);
  371. extern VOID hsc_set_entity_mode(HSCPRC * hp, LONG new_mode);
  372.  
  373. /* methodes for include-directories */
  374. extern BOOL hsc_add_include_directory(HSCPRC * hp, STRPTR dir);
  375. extern VOID hsc_clr_include_directory(HSCPRC * hp);
  376.  
  377. /* get-methodes for flags */
  378. extern BOOL hsc_get_chkid(HSCPRC * hp);
  379. extern BOOL hsc_get_chkuri(HSCPRC * hp);
  380. extern BOOL hsc_get_compact(HSCPRC * hp);
  381. extern BOOL hsc_get_debug(HSCPRC * hp);
  382. extern BOOL hsc_get_getsize(HSCPRC * hp);
  383. extern BOOL hsc_get_htmlonly(HSCPRC * hp);
  384. extern BOOL hsc_get_jerkvalues(HSCPRC * hp);
  385. extern BOOL hsc_get_jens(HSCPRC * hp);
  386. extern BOOL hsc_get_rplc_ent(HSCPRC * hp);
  387. extern BOOL hsc_get_rplc_quote(HSCPRC * hp);
  388. extern BOOL hsc_get_smart_ent(HSCPRC * hp);
  389. extern BOOL hsc_get_strip_badws(HSCPRC * hp);
  390. extern BOOL hsc_get_strip_cmt(HSCPRC * hp);
  391. extern BOOL hsc_get_strip_ext(HSCPRC * hp);
  392.  
  393. /* get-methodes for internal flags */
  394. extern BOOL hsc_get_fatal(HSCPRC * hp);
  395. extern BOOL hsc_get_inside_anchor(HSCPRC * hp);
  396. extern BOOL hsc_get_inside_pre(HSCPRC * hp);
  397. extern BOOL hsc_get_suppress_output(HSCPRC * hp);
  398.  
  399. /* get-methodes for values */
  400. extern STRPTR hsc_get_destdir(HSCPRC * hp);
  401. extern STRPTR hsc_get_reldir(HSCPRC * hp);
  402. extern STRPTR hsc_get_iconbase(HSCPRC * hp);
  403. extern STRPTR hsc_get_server_dir(HSCPRC * hp);
  404.  
  405. /* get-methodes for internal values */
  406. extern STRPTR hsc_get_click_here_str(HSCPRC * hp);
  407. extern STRPTR hsc_get_file_name(HSCPRC * hp);
  408. extern ULONG hsc_get_file_line(HSCPRC * hp);
  409. extern ULONG hsc_get_file_column(HSCPRC * hp);
  410. extern ULONG hsc_get_msg_count(HSCPRC * hp);
  411.  
  412. /* methodes for messages */
  413. extern BOOL hsc_get_msg_ignore_notes(HSCPRC * hp);
  414. extern BOOL hsc_get_msg_ignore_style(HSCPRC * hp);
  415. extern BOOL hsc_get_msg_ignore_port(HSCPRC * hp);
  416. extern BOOL hsc_set_msg_ignore_notes(HSCPRC * hp, BOOL value);
  417. extern BOOL hsc_set_msg_ignore_style(HSCPRC * hp, BOOL value);
  418. extern BOOL hsc_set_msg_ignore_port(HSCPRC * hp, BOOL value);
  419. extern BOOL hsc_set_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id, HSCIGN value);
  420. extern HSCIGN hsc_get_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id);
  421. extern BOOL hsc_set_msg_class(HSCPRC * hp, HSCMSG_ID msg_id, HSCMSG_CLASS msg_class);
  422. extern HSCMSG_CLASS hsc_get_msg_class(HSCPRC * hp, HSCMSG_ID msg_id);
  423. extern VOID hsc_clear_msg_ignore(HSCPRC * hp);
  424. extern VOID hsc_reset_msg_class(HSCPRC * hp);
  425.  
  426. /* output function */
  427. extern STRPTR compactWs(HSCPRC * hp, STRPTR ws);
  428. extern BOOL hsc_output_text(HSCPRC * hp, STRPTR wspc, STRPTR text);
  429.  
  430. /* misc. functions */
  431. extern BOOL hsc_standard_nomem_handler(size_t size);
  432.  
  433. #endif /* NOEXTERN_HSC_HSCPRC */
  434. #endif /* HSC_HSCPRC_H */
  435.